home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / FCOPY.AML < prev    next >
Text File  |  1996-07-17  |  3KB  |  117 lines

  1. //--------------------------------------------------------------------
  2. // FCOPY.AML
  3. // File manager - Copy files, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro prompts you to copy or move one or more files.
  6. //
  7. // If run from an edit window, the current file is copied to the
  8. // specified destiniation.
  9. //
  10. // If run from a file manager window, the current file (or marked
  11. // files), are copied or moved to the specified destination.
  12. //
  13. // This macro may also call the Sweep macro.
  14. //
  15. // Usage:
  16. //
  17. // Select this macro from the Macro List (on the Macro menu), or run it
  18. // from the macro picklist <shift f12>.
  19. //
  20. // This macro can also be run from the file manager by selecting Copy
  21. // or Move from the file manager Command menu.
  22. //--------------------------------------------------------------------
  23.  
  24. // compile time macros and function definitions
  25. include bootpath "define.aml"
  26.  
  27. // fmgr copy/move file(s) command
  28. function fcopy2 (source dest options)
  29.   sourcedir = source [LAST_CHAR] == '\\'
  30.   if dir? dest then
  31.     dest = qualify (getname (if? sourcedir source [1..length source - 1]
  32.                                            source)) dest
  33.   end
  34.   // copying/moving directories
  35.   if sourcedir then
  36.     if pos "*.*" dest then
  37.       dest = (getpath dest) + (getname source [1..length source - 1])
  38.     end
  39.     action = 'r'
  40.     if directory? dest then
  41.       if (popup "ok" dest + " Exists. Overwrite?") [1] <> 'O' then
  42.         action = ''
  43.       end
  44.     end
  45.     //action = askrac dest
  46.     dest = dest + '\\'
  47.   else
  48.     action = askrac dest
  49.   end
  50.   if pos action "ra" 'i' then
  51.     move? = options == 'm'
  52.     say (if? move? "Mov" "Copy") + "ing " + source + "..."
  53.     success = TRUE
  54.     if not move? or (icompare action 'a') or not (renamefile source dest) then
  55.       // copying/moving directory
  56.       success = if sourcedir then
  57.                   runmacro (bootpath "macro\\sweep.x") ''
  58.                              source dest 'c' + (if? move? 'd')
  59.                 else
  60.                   copyfile source dest (if? (icompare action 'a') 'a')
  61.                 end
  62.     end
  63.     if success then
  64.       if source [LAST_CHAR] == '\\' then
  65.         source [LAST_CHAR] = ''
  66.         if dest [LAST_CHAR] == '\\' then
  67.           dest [LAST_CHAR] = ''
  68.         end
  69.       end
  70.       if (icompare (getpath source) (getpath dest)) then
  71.         finsert dest
  72.       end
  73.       if move? then
  74.         if not sourcedir then
  75.           deletefile source
  76.         end
  77.         delline
  78.       end
  79.     else
  80.       msgbox (if? move? "Move" "Copy") + " Failed"  "Error!" 'b'
  81.       fbreak
  82.     end
  83.   end
  84. end
  85.  
  86. options = arg 3
  87.  
  88. // check for edit/fmgr windows
  89. if not wintype? "edit_fmgr" then
  90.   msgbox "File Manager Windows and Edit Windows windows only!"
  91. end
  92.  
  93. fmgrtype = wintype? "fmgr"
  94. bufname = getbufname
  95.  
  96. if fmgrtype and fmark? then
  97.   dir_dest = qualify (fgetfile)
  98.   if not dir? dir_dest then
  99.     dir_dest = ''
  100.   end
  101. end
  102.  
  103. // get destination
  104. dest = ask (if? options == 'm' "Move" "Copy") + ' ' +
  105.             (if? fmgrtype (fname) (onname (getname bufname))) + " to"
  106.            "_load" dir_dest
  107.  
  108. // do the copy
  109. if dest then
  110.   dest = qualify dest bufname
  111.   if fmgrtype then
  112.     fcommand "fcopy2" dest options
  113.   else
  114.     fcopy2 bufname dest options
  115.   end
  116. end
  117.